#include <iostream>

// copied from online tutorial.
#define CHECK_CUDA_ERROR(val) check((val), #val, __FILE__, __LINE__)
template <typename T>
void check(
    T err,
    char const* const func,
    char const* const file,
    int const line) {
  if (err != cudaSuccess) {
    std::cerr << "CUDA Runtime Error at: " << file << ":" << line << std::endl;
    std::cerr << cudaGetErrorString(err) << " " << func << std::endl;
    // std::exit(EXIT_FAILURE);
  }
}
